﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>人员信息添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="UserID" class="layui-form-label">
                    <span class="we-red">*</span>用户名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="UserID" name="UserID" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="UserName" class="layui-form-label">
                    <span class="we-red">*</span>姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="UserName" name="UserName" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="DeptID" class="layui-form-label">
                    <span class="we-red">*</span>部门
                </label>
                <div class="layui-input-inline">
                    <select id="DeptID" name="DeptID" autocomplete="off" class="valid"></select>
                </div>
                <!--<label for="UserSFZH" class="layui-form-label">
        <span class="we-red">*</span>身份证号
    </label>
    <div class="layui-input-inline">
        <input type="text" id="UserSFZH" name="UserSFZH" lay-verify="required|sfzh" autocomplete="off" class="layui-input">
    </div>
    <label for="EmpID" class="layui-form-label">
        <span class="we-red">*</span>人员编号
    </label>
    <div class="layui-input-inline">
        <input type="text" id="UserNo" name="UserNo" lay-verify="required" autocomplete="off" class="layui-input">
    </div>-->
            </div>
            <div class="layui-form-item">
                <!--<label for="UserSGZH" class="layui-form-label">
        <span class="we-red">*</span>上岗证号
    </label>
    <div class="layui-input-inline">
        <input type="text" id="UserSGZH" name="UserSGZH" lay-verify="required" autocomplete="off" class="layui-input">
    </div>-->
                <label for="UserPwd" class="layui-form-label">
                    <span class="we-red">*</span>登录密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="UserPwd" name="UserPwd" lay-verify="required|pass" autocomplete="off" class="layui-input">
                </div>
                <label for="ReUserPwd" class="layui-form-label">
                    <span class="we-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="ReUserPwd" name="ReUserPwd" lay-verify="required|repass" autocomplete="off" class="layui-input">
                </div>
                <label for="Post" class="layui-form-label">
                    职务
                </label>
                <div class="layui-input-inline">
                    <input id="Post" name="Post" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="Sex" class="layui-form-label">性别</label>
                <div class="layui-input-inline" id="EmpSex">
                    <input type="radio" name="Sex" value="男" title="男" checked>
                    <input type="radio" name="Sex" value="女" title="女">
                </div>
                <label for="Nation" class="layui-form-label">
                    民族
                </label>
                <div class="layui-input-inline">
                    <select id="Nation" name="Nation" autocomplete="off" class="valid"></select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="RoleID" class="layui-form-label">
                    角色
                </label>
                <div class="layui-input-inline">
                    <select id="RoleID" name="RoleID" autocomplete="off" class="valid"></select>
                </div>

                <label for="Post" class="layui-form-label">
                    指导组
                </label>
                <div class="layui-input-inline">
                    <select id="GroupsOrderNum" name="GroupsOrderNum" class="select" lay-filter="GroupsOrderNum" lay-verify="type" autocomplete="off" >
                        <option value="1">第一指导组</option>
                        <option value="2">第二指导组</option>
                        <option value="3">第三指导组</option>
                        <option value="4">第四指导组</option>
                        <option value="5">第五指导组</option>
                        <option value="6">第六指导组</option>
                        <option value="7">第七指导组</option>
                        <option value="8">第八指导组</option>
                        <option value="9">第九指导组</option>
                    </select>
                </div>
                
                <div  class="layui-input-inline">
                    <input type="hidden" id="Groups" name="Groups" value="第一指导组" autocomplete="off" class="layui-input">
                </div>
                <!--<label for="WorkBeforeEdu" class="layui-form-label">
        工作前文化
    </label>
    <div class="layui-input-inline">
        <input type="text" id="WorkBeforeEdu" name="WorkBeforeEdu" lay-verify="required" autocomplete="off" class="layui-input">
    </div>-->
            </div>
            <!--<div class="layui-form-item">
                <label for="CurrentEdu" class="layui-form-label">
                    现有文化
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="CurrentEdu" name="CurrentEdu" lay-verify="required|nikename" autocomplete="off" class="layui-input">
                </div>
                <label for="Politic" class="layui-form-label">
                    政治面貌
                </label>
                <div class="layui-input-inline">
                    <select id="Politic" name="Politic" autocomplete="off" class="layui-input">
                        <option value=""></option>
                        <option value="团员">团员</option>
                        <option value="党员">党员</option>
                        <option value="预备党员">预备党员</option>
                        <option value="无党人士">无党人士</option>
                        <option value="群众">群众</option>
                    </select>
                    </div>
                    <label for="Birthday" class="layui-form-label">
                        出生日期
                    </label>
                    <div class="layui-input-inline">
                        <input class="layui-input" id="Birthday" name="Birthday" type="text" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            <div class="layui-form-item">
                <label for="BeginWorkDate" class="layui-form-label">
                    参加工作时间
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="BeginWorkDate" name="BeginWorkDate" type="text" placeholder="yyyy-MM-dd">
                </div>
                <label for="AppointmentDate" class="layui-form-label">
                    定职时间
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="AppointmentDate" name="AppointmentDate" type="text" placeholder="yyyy-MM-dd">
                </div>
                <label for="InTime" class="layui-form-label">
                    任现职时间
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="InTime" name="InTime" type="text" placeholder="yyyy-MM-dd">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="EmployeeStatus" class="layui-form-label">
                    职工身份
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="EmployeeStatus" name="EmployeeStatus" autocomplete="off" class="layui-input">
                </div>
                <label for="TechnicalGrade" class="layui-form-label">
                    技术等级
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="TechnicalGrade" name="TechnicalGrade" autocomplete="off" class="layui-input">
                </div>
                <label for="TechnicalPost" class="layui-form-label">
                    技术职务
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="TechnicalPost" autocomplete="off" id="TechnicalPost">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="IsGT" class="layui-form-label">
                    是否高铁
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" id="IsGT" name="IsGT" lay-skin="switch" lay-text="是|否">
                </div>
                <label for="IsBZZ" class="layui-form-label">
                    是否班组长
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" id="IsBZZ" name="IsBZZ" lay-skin="switch" lay-text="是|否">
                </div>
                <label for="isTYZYGZ" class="layui-form-label">
                    特有职业工种
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" id="isTYZYGZ" name="isTYZYGZ" lay-skin="switch" lay-text="是|否">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="IsZYXCGZ" class="layui-form-label">
                    主要行车工种
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" id="IsZYXCGZ" name="IsZYXCGZ" lay-skin="switch" lay-text="是|否">
                </div>
                <label for="PostStatus" class="layui-form-label">
                    在岗状态
                </label>
                <div class="layui-input-inline">
                    <select id="PostStatus" name="PostStatus" autocomplete="off" class="layui-input">
                        <option value="在岗">在岗</option>
                        <option value="脱岗">脱岗</option>
                    </select>
                </div>
                <label for="UserID7" class="layui-form-label">
                    7位乘务员工号
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="UserID7" autocomplete="off" id="UserID7">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="DriverType" class="layui-form-label">
                    可驾驶机型
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="DriverType" name="DriverType" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="DriverLicense" class="layui-form-label">
                    驾驶证类别
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="DriverLicense" autocomplete="off" id="DriverLicense">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="define1" class="layui-form-label">
                    备注一
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="define1" autocomplete="off" id="define1">
                </div>
                <label for="define2" class="layui-form-label">
                    备注二
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="define2" name="define2" autocomplete="off" class="layui-input">
                </div>
                <label for="define3" class="layui-form-label">
                    备注三
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="define3" name="define3" autocomplete="off" class="layui-input">
                </div>
            </div>-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="add">确定</button>
                </div>
            </div>
        </form>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'jquery', 'layer', 'laydate'], function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer,
                laydate = layui.laydate;
            $.support.cors = true;
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            //日期时间选择器
            laydate.render({
                elem: '#Birthday'
                //, type: 'datetime'
            });
            //日期时间选择器
            laydate.render({
                elem: '#BeginWorkDate'
                //, type: 'datetime'
            });
            //日期时间选择器
            laydate.render({
                elem: '#AppointmentDate'
                //, type: 'datetime'
            });
            //日期时间选择器
            laydate.render({
                elem: '#InTime'
                //, type: 'datetime'
            });
            //自定义验证规则
            form.verify({
                nikename: function (value) {
                    if (value.length < 2) {
                        return '姓名至少2个字符';
                    }
                },
                sfzh: [/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,'身份证号格式不正确'],
                pass: [/(.+){6,12}$/, '密码必须6到12位'],
                repass: function (value) {
                    if ($('#UserPwd').val() != $('#ReUserPwd').val()) {
                        return '两次密码不一致';
                    }
                }
            });
            $(function () {
                //加载民族
                var nations = ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族",
                    "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族",
                    "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族",
                    "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族"];
                var staff_nation = document.getElementById("Nation");
                for (var i in nations) {
                    staff_nation.add(new Option(nations[i], nations[i]));
                }
                form.render();
                //加载部门信息，角色信息，机务段信息
                $.ajax({
                    url: ApiUrl + "Dep/Sel",
                    type: 'post',
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            $(data.Data).each(function (index, item) {
                                $("#DeptID").append("<option value='" + item.DepID + "'>" + item.DepName + "</option>");
                            });
                            form.render();
                        }
                    }
                });
                $.ajax({
                    url: ApiUrl + "Role/Sel",
                    type: 'post',
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            $(data.Data).each(function (index, item) {
                                $("#RoleID").append("<option value='" + item.RoleID + "'>" + item.RoleName + "</option>");
                            });
                            form.render();
                        }
                    }
                });
                
            });
            
            form.on('select(GroupsOrderNum)', function (data) {
                $("#Groups").val($("#GroupsOrderNum").find("option:selected").text());

            })

            //监听提交
            form.on('submit(add)', function (formdata) {
                $.ajax({
                    url: ApiUrl + "UserInfo/Add",
                    type: 'post',
                    dataType: 'json',
                    data: formdata.field,
                    success: function (data) {
                        if (data.StatusCode == 200 && data.Count != 0) {
                            layer.alert(data.Info, { icon: 6 }, function (index) {
                                parent.layer.closeAll();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>